<?php
//
// test HTTP POST submitter, using libcurl
//
include_once "config.php";
include_once "common.php";


$auth =  $_COOKIE[$th_auth];
$username = $_COOKIE[$th_username];

//$subject_id = '6985';//debug
$ep_id = $_POST["ep_id"];
$status = $_POST["status"];
$subject_id;
if(isset($_POST["subject_id"])){
	$subject_id  = $_POST["subject_id"];	
}

//$ep_id = '77559';
//$status = 'watched';

if ($auth && !empty($auth) && $username && !empty($username)){

	$action_url = 'http://api.bgm.tv/ep/'.$ep_id.'/status/';
	$action_url = $action_url.$status;
	$action_url = $action_url.'?source='.$source;

	$post_data = array ( 'auth' => ($auth) );
	$update = curl_post($action_url, $post_data);



	returnError($update);
	
	if ($subject_id){
		$action_url = 'http://api.bgm.tv/collection/'.$subject_id.'/update?source='.$source;
		//$action_url = $action_url.'?source='.$source;
	
		$post_data = array ( 'status' => ('do'),'auth' => ($auth));
	
	
		$update2 = curl_post($action_url, $post_data);
	
	
	
		returnError($update2);

	}




	print $update;
	


}
else{
printError();
}





?>